package com.molichuxing.gateway.bff.permission.services.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.molichuxing.framework.dto.Paged;
import com.molichuxing.gateway.bff.permission.convertor.Convert;
import com.molichuxing.gateway.bff.permission.entity.request.create.OperationLogCreateVo;
import com.molichuxing.gateway.bff.permission.entity.response.OperationLogVo;
import com.molichuxing.gateway.bff.permission.services.OperationLogBffService;
import com.molichuxing.gateway.bff.user.entity.response.UserVo;
import com.molichuxing.services.infrastructure.dto.response.UserDto;
import com.molichuxing.services.infrastructure.dto.response.response.OperationLogDto;
import com.molichuxing.services.infrastructure.service.OperationLogService;

@Service("operationLogBffService")
public class OperationLogBffServiceImpl implements OperationLogBffService {

	private static final Logger logger = LoggerFactory.getLogger(OperationLogBffServiceImpl.class);


	@Resource
	private OperationLogService operationLogService;

	@Override
	public Boolean createOperationLog(OperationLogCreateVo createVo) throws Exception{
		return operationLogService.createOperationLog(Convert.toOperationLogCreateDto(createVo));
	}
	
	@Override
	public Paged<OperationLogVo> getOperationLog(Map<String, Object> map, Integer pageNum, Integer pageSize) {
		
		Paged<OperationLogDto> paged = operationLogService.getOperationLogPage(map, pageNum, pageSize);
		if(null == paged) {
			return new Paged<>();
		}else if(paged.isEmpty()) {
			return new Paged<>(null,paged.getTotal(),paged.getPageSize());
		}
		
		List<OperationLogDto> list = paged.getList();
		List<OperationLogVo> operationLogVoList = Convert.toOperationLogVoPage(list);
		
		Paged<OperationLogVo> page=new Paged<>(operationLogVoList,paged.getTotal(),pageSize);
		return page;
	}

	
}
